package com.Dao;

import com.Bean.Good;
import com.Bean.Provider;
import com.Common.PageInfo;

import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: hkw14
 * @time: 2021/5/6 11:22
 */
public class ProviderDao extends BaseDao{
    public PageInfo<Provider> selectPage(Map<String,Object> params, Integer page, Integer limit) {
        String sql = "select * from `provider` where";
        if(params.containsKey("providerName")) {
            sql = sql + "  providerName like '%"+params.get("providerName")+"%'   and";
        }
        if(sql.endsWith("and")) {
            sql = sql.substring(0,sql.lastIndexOf("and"));
        }
        if(sql.endsWith("where")) {
            sql = sql.substring(0,sql.lastIndexOf("where"));
        }
        return this.selectPage(sql,Provider.class, page, limit);
    }
    public List<Provider> getProviderList(){
        String sql = "select * from `provider`";
        List<Provider> providers = this.selectList(sql, Provider.class);
        return providers;
    }
}
